﻿namespace AI3SaveEditor {
    using Microsoft.VisualBasic;
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Globalization;
    using System.IO;
    using System.Runtime.CompilerServices;
    using System.Text;
    using System.Windows.Forms;


    internal sealed class IllusionUtils {
        public static string GetStringWithTrimNull(byte[] buf, int start, int length) {
            return Encoding.Default.GetString(buf, start, length).TrimEnd('\0');
        }

        public static void SetInt32(int value, byte[] buffer, int start) {
            byte[] bytes = BitConverter.GetBytes(value);
            for (int i = 0; i < bytes.Length; i++)
                buffer[start + i] = bytes[i];
        }

        internal static void SetString(string value, byte[] buffer, int start, int length) {
            int index = start;
            byte[] bytes = Encoding.Default.GetBytes(value);
            for (int i = 0; i < length; i++) {
                buffer[start + i] = (bytes.Length > i) ? bytes[i] : byte.MinValue;
            }
        }

        public static byte[] CloneBytes(byte[] bytes, int index) {
            byte[] result = new byte[bytes.Length];
            bytes.CopyTo(result, index);
            return result;
        }

        public class cl_global_game_data {
            public bool addon1_active;
            public string addon1_description;
            public string addon1_exe;
            public string addon1_lstppfile;
            public bool addon1_manual_path;
            public string addon1_path;
            public string addon1_ppfilepath;
            public string addon1_regkey;
            public string addon1_regkey_a1;
            public string addon1_regkey_a2;
            public string addon1_regkey_a3;
            public string addon1_regname;
            public string addon1ID;
            public bool addon2_active;
            public string addon2_description;
            public string addon2_exe;
            public string addon2_lstppfile;
            public bool addon2_manual_path;
            public string addon2_path;
            public string addon2_ppfilepath;
            public string addon2_regkey;
            public string addon2_regkey_a1;
            public string addon2_regkey_a2;
            public string addon2_regkey_a3;
            public string addon2_regname;
            public string addon2ID;
            public bool addon3_active;
            public string addon3_description;
            public string addon3_exe;
            public string addon3_lstppfile;
            public bool addon3_manual_path;
            public string addon3_path;
            public string addon3_ppfilepath;
            public string addon3_regkey;
            public string addon3_regkey_a1;
            public string addon3_regkey_a2;
            public string addon3_regkey_a3;
            public string addon3_regname;
            public string addon3ID;
            public bool addon4_active;
            public string addon4_description;
            public string addon4_exe;
            public string addon4_lstppfile;
            public bool addon4_manual_path;
            public string addon4_path;
            public string addon4_ppfilepath;
            public string addon4_regkey;
            public string addon4_regkey_a1;
            public string addon4_regkey_a2;
            public string addon4_regkey_a3;
            public string addon4_regname;
            public string addon4ID;
            public bool allow_collision_check;
            public byte collision_check;
            public bool detailed_logging;
            public string error_text;
            public bool expert_mode;
            public int free_space_warning_MB;
            public string game_description;
            public long game_drive_free_space_MB;
            public string game_exe;
            public string game_lstppfile;
            public bool game_M_COS_active;
            public bool game_M_TEX_active;
            public bool game_manual_path;
            public string game_path;
            public string game_ppfilepath;
            public string game_regkey;
            public string game_regkey_a1;
            public string game_regkey_a2;
            public string game_regkey_a3;
            public string game_regname;
            public bool game_TGA_INSERT_active;
            public string gameID;
            public int global_check_status;
            public string picture_switch_time;
            public bool picture_switching;
            public string ppdecrypter;
            public string ppdecrypter_enc_or_dec_lst_files;
            public string ppdecrypter_fileonly;
            public bool unicode_install_dir;
            public int window_height;
            public int window_location_x;
            public int window_location_y;
            public string wizzard_backups_path;
            public string wizzard_descriptions_path;
            public long wizzard_drive_free_space_MB;
            public string wizzard_ini_file;
            public string wizzard_mods_path;
            public string wizzard_pp_temp_path;
            public string wizzard_previews_path;
            public string wizzard_queue_file;
            public string wizzard_temp_path;

            public void check_free_disk_space() {
                MsgBoxResult yes = MsgBoxResult.Yes;
                if ((this.free_space_warning_MB > this.game_drive_free_space_MB) & (this.free_space_warning_MB > this.wizzard_drive_free_space_MB)) {
                    yes = Interaction.MsgBox("The game drive and the wizzard drive do have low free disk space\rThe specified warning limit is: " + Conversions.ToString(this.free_space_warning_MB) + " MB\rFree space on game drive: " + Conversions.ToString(this.game_drive_free_space_MB) + " MB\rFree space on wizzard drive: " + Conversions.ToString(this.wizzard_drive_free_space_MB) + " MB\r\rDo you still want to use illusion wizzard (recomendation is no)", MsgBoxStyle.Exclamation | MsgBoxStyle.YesNo, null);
                }
                else if (this.free_space_warning_MB > this.game_drive_free_space_MB) {
                    yes = Interaction.MsgBox("The game drive does have low free disk space\rThe specified warning limit is: " + Conversions.ToString(this.free_space_warning_MB) + " MB\rFree space on game drive: " + Conversions.ToString(this.game_drive_free_space_MB) + " MB\rFree space on wizzard drive: " + Conversions.ToString(this.wizzard_drive_free_space_MB) + " MB\r\rDo you still want to use illusion wizzard (recomendation is no)", MsgBoxStyle.Exclamation | MsgBoxStyle.YesNo, null);
                }
                else if (this.free_space_warning_MB > this.wizzard_drive_free_space_MB) {
                    yes = Interaction.MsgBox("The wizzard drive does have low free disk space\rThe specified warning limit is: " + Conversions.ToString(this.free_space_warning_MB) + " MB\rFree space on game drive: " + Conversions.ToString(this.game_drive_free_space_MB) + " MB\rFree space on wizzard drive: " + Conversions.ToString(this.wizzard_drive_free_space_MB) + " MB\r\rDo you still want to use illusion wizzard (recomendation is no)", MsgBoxStyle.Exclamation | MsgBoxStyle.YesNo, null);
                }
                if (yes == MsgBoxResult.No) {
                    Application.Exit();
                }
            }

            public void check_remove_write_protection() {
                if ((this.game_ppfilepath != null) && (this.game_ppfilepath.Length > 1)) {
                    FileInfo[] files = new DirectoryInfo(this.game_ppfilepath).GetFiles("*.pp");
                    int num = 0;
                    foreach (FileInfo info2 in files) {
                        if (info2.IsReadOnly) {
                            MsgBoxResult result = MsgBoxResult.Ok;
                            if (num == 0) {
                                result = Interaction.MsgBox("A read only pp file was found in " + this.game_ppfilepath + "\rDo you want wizzard to remove the write protection for this file and all other pp files that do have a write protection", MsgBoxStyle.Question | MsgBoxStyle.YesNo, null);
                                if (result == MsgBoxResult.Yes) {
                                    info2.IsReadOnly = false;
                                }
                            }
                            else if (result == MsgBoxResult.Yes) {
                                info2.IsReadOnly = false;
                            }
                            num++;
                        }
                    }
                    if (num != 0) {
                        Interaction.MsgBox("The read only attribute has been removed for " + Conversions.ToString(num) + " pp files", MsgBoxStyle.Information, null);
                    }
                }
            }

            //public void get_game_data() {
            //    if ((this.gameID == null) | (this.gameID == "")) {
            //        this.error_text = "Parameter file has not been specified.";
            //    }
            //    else {
            //        string path = Application.StartupPath + @"\_general\game_profiles\" + this.gameID + ".pro";
            //        if (!File.Exists(path)) {
            //            this.error_text = "Parameter file for game: " + this.gameID + " is missing.";
            //        }
            //        else {
            //            int num = 0;
            //            StreamReader reader = new StreamReader(path);
            //            string str13 = "";
            //            string str2 = "";
            //            string str4 = "";
            //            string str6 = "";
            //            string str8 = "";
            //            string str10 = "";
            //            string str = "";
            //            string str3 = "";
            //            string str5 = "";
            //            string str7 = "";
            //            this.game_description = "";
            //            this.addon1_description = "";
            //            this.addon2_description = "";
            //            this.addon3_description = "";
            //            this.addon4_description = "";
            //            this.game_TGA_INSERT_active = false;
            //            this.game_M_TEX_active = false;
            //            this.game_M_COS_active = false;
            //            this.free_space_warning_MB = 0;
            //            while (!reader.EndOfStream) {
            //                string str11 = reader.ReadLine();
            //                if (str11.StartsWith("game_description = ")) {
            //                    this.game_description = Strings.Mid(str11, 20, str11.Length - 0x13);
            //                }
            //                if (str11.StartsWith("game_regkey = ")) {
            //                    this.game_regkey = Strings.Mid(str11, 15, str11.Length - 14);
            //                }
            //                if (str11.StartsWith("game_regkey_a1 = ")) {
            //                    this.game_regkey_a1 = Strings.Mid(str11, 0x12, str11.Length - 0x11);
            //                }
            //                if (str11.StartsWith("game_regkey_a2 = ")) {
            //                    this.game_regkey_a2 = Strings.Mid(str11, 0x12, str11.Length - 0x11);
            //                }
            //                if (str11.StartsWith("game_regkey_a3 = ")) {
            //                    this.game_regkey_a3 = Strings.Mid(str11, 0x12, str11.Length - 0x11);
            //                }
            //                if (str11.StartsWith("game_regname = ")) {
            //                    this.game_regname = Strings.Mid(str11, 0x10, str11.Length - 15);
            //                }
            //                if (str11.StartsWith("game_lstppfile = ")) {
            //                    str10 = Strings.Mid(str11, 0x12, str11.Length - 0x11);
            //                }
            //                if (str11.StartsWith("game_ppfilepath = ")) {
            //                    str13 = Strings.Mid(str11, 0x13, str11.Length - 0x12);
            //                }
            //                if (str11.StartsWith("game_TGA_INSERT_active = 1")) {
            //                    this.game_TGA_INSERT_active = true;
            //                }
            //                if (str11.StartsWith("game_M_TEX_active = 1")) {
            //                    this.game_M_TEX_active = true;
            //                }
            //                if (str11.StartsWith("game_M_COS_active = 1")) {
            //                    this.game_M_COS_active = true;
            //                }
            //                if (str11.StartsWith("addon1ID = ")) {
            //                    this.addon1ID = Strings.Mid(str11, 12, str11.Length - 11);
            //                }
            //                if (str11.StartsWith("addon1_description = ")) {
            //                    this.addon1_description = Strings.Mid(str11, 0x16, str11.Length - 0x15);
            //                }
            //                if (str11.StartsWith("addon1_regkey = ")) {
            //                    this.addon1_regkey = Strings.Mid(str11, 0x11, str11.Length - 0x10);
            //                }
            //                if (str11.StartsWith("addon1_regkey_a1 = ")) {
            //                    this.addon1_regkey_a1 = Strings.Mid(str11, 20, str11.Length - 0x13);
            //                }
            //                if (str11.StartsWith("addon1_regkey_a2 = ")) {
            //                    this.addon1_regkey_a2 = Strings.Mid(str11, 20, str11.Length - 0x13);
            //                }
            //                if (str11.StartsWith("addon1_regkey_a3 = ")) {
            //                    this.addon1_regkey_a3 = Strings.Mid(str11, 20, str11.Length - 0x13);
            //                }
            //                if (str11.StartsWith("addon1_regname = ")) {
            //                    this.addon1_regname = Strings.Mid(str11, 0x12, str11.Length - 0x11);
            //                }
            //                if (str11.StartsWith("addon1_lstppfile = ")) {
            //                    str = Strings.Mid(str11, 20, str11.Length - 0x13);
            //                    if (str == " ") {
            //                        str = "";
            //                    }
            //                }
            //                if (str11.StartsWith("addon1_ppfilepath = ")) {
            //                    str2 = Strings.Mid(str11, 0x15, str11.Length - 20);
            //                }
            //                if (str11.StartsWith("addon2ID = ")) {
            //                    this.addon2ID = Strings.Mid(str11, 12, str11.Length - 11);
            //                }
            //                if (str11.StartsWith("addon2_description = ")) {
            //                    this.addon2_description = Strings.Mid(str11, 0x16, str11.Length - 0x15);
            //                }
            //                if (str11.StartsWith("addon2_regkey = ")) {
            //                    this.addon2_regkey = Strings.Mid(str11, 0x11, str11.Length - 0x10);
            //                }
            //                if (str11.StartsWith("addon2_regkey_a1 = ")) {
            //                    this.addon2_regkey_a1 = Strings.Mid(str11, 20, str11.Length - 0x13);
            //                }
            //                if (str11.StartsWith("addon2_regkey_a2 = ")) {
            //                    this.addon2_regkey_a2 = Strings.Mid(str11, 20, str11.Length - 0x13);
            //                }
            //                if (str11.StartsWith("addon2_regkey_a3 = ")) {
            //                    this.addon2_regkey_a3 = Strings.Mid(str11, 20, str11.Length - 0x13);
            //                }
            //                if (str11.StartsWith("addon2_regname = ")) {
            //                    this.addon2_regname = Strings.Mid(str11, 0x12, str11.Length - 0x11);
            //                }
            //                if (str11.StartsWith("addon2_lstppfile = ")) {
            //                    str3 = Strings.Mid(str11, 20, str11.Length - 0x13);
            //                    if (str3 == " ") {
            //                        str3 = "";
            //                    }
            //                }
            //                if (str11.StartsWith("addon2_ppfilepath = ")) {
            //                    str4 = Strings.Mid(str11, 0x15, str11.Length - 20);
            //                }
            //                if (str11.StartsWith("addon3ID = ")) {
            //                    this.addon3ID = Strings.Mid(str11, 12, str11.Length - 11);
            //                }
            //                if (str11.StartsWith("addon3_description = ")) {
            //                    this.addon3_description = Strings.Mid(str11, 0x16, str11.Length - 0x15);
            //                }
            //                if (str11.StartsWith("addon3_regkey = ")) {
            //                    this.addon3_regkey = Strings.Mid(str11, 0x11, str11.Length - 0x10);
            //                }
            //                if (str11.StartsWith("addon3_regkey_a1 = ")) {
            //                    this.addon3_regkey_a1 = Strings.Mid(str11, 20, str11.Length - 0x13);
            //                }
            //                if (str11.StartsWith("addon3_regkey_a2 = ")) {
            //                    this.addon3_regkey_a2 = Strings.Mid(str11, 20, str11.Length - 0x13);
            //                }
            //                if (str11.StartsWith("addon3_regkey_a3 = ")) {
            //                    this.addon3_regkey_a3 = Strings.Mid(str11, 20, str11.Length - 0x13);
            //                }
            //                if (str11.StartsWith("addon3_regname = ")) {
            //                    this.addon3_regname = Strings.Mid(str11, 0x12, str11.Length - 0x11);
            //                }
            //                if (str11.StartsWith("addon3_lstppfile = ")) {
            //                    str5 = Strings.Mid(str11, 20, str11.Length - 0x13);
            //                    if (str5 == " ") {
            //                        str5 = "";
            //                    }
            //                }
            //                if (str11.StartsWith("addon3_ppfilepath = ")) {
            //                    str6 = Strings.Mid(str11, 0x15, str11.Length - 20);
            //                }
            //                if (str11.StartsWith("addon4ID = ")) {
            //                    this.addon4ID = Strings.Mid(str11, 12, str11.Length - 11);
            //                }
            //                if (str11.StartsWith("addon4_description = ")) {
            //                    this.addon4_description = Strings.Mid(str11, 0x16, str11.Length - 0x15);
            //                }
            //                if (str11.StartsWith("addon4_regkey = ")) {
            //                    this.addon4_regkey = Strings.Mid(str11, 0x11, str11.Length - 0x10);
            //                }
            //                if (str11.StartsWith("addon4_regkey_a1 = ")) {
            //                    this.addon4_regkey_a1 = Strings.Mid(str11, 20, str11.Length - 0x13);
            //                }
            //                if (str11.StartsWith("addon4_regkey_a2 = ")) {
            //                    this.addon4_regkey_a2 = Strings.Mid(str11, 20, str11.Length - 0x13);
            //                }
            //                if (str11.StartsWith("addon4_regkey_a3 = ")) {
            //                    this.addon4_regkey_a3 = Strings.Mid(str11, 20, str11.Length - 0x13);
            //                }
            //                if (str11.StartsWith("addon4_regname = ")) {
            //                    this.addon4_regname = Strings.Mid(str11, 0x12, str11.Length - 0x11);
            //                }
            //                if (str11.StartsWith("addon4_lstppfile = ")) {
            //                    str7 = Strings.Mid(str11, 20, str11.Length - 0x13);
            //                    if (str7 == " ") {
            //                        str7 = "";
            //                    }
            //                }
            //                if (str11.StartsWith("addon4_ppfilepath = ")) {
            //                    str8 = Strings.Mid(str11, 0x15, str11.Length - 20);
            //                }
            //                if (str11.StartsWith("allow_collision_check = ")) {
            //                    if (Strings.Mid(str11, 0x19, str11.Length - 0x18) == "1") {
            //                        this.allow_collision_check = true;
            //                    }
            //                    else {
            //                        this.allow_collision_check = false;
            //                    }
            //                }
            //                if (str11.StartsWith("ppdecrypter = ") && ((Strings.Mid(str11, 15, str11.Length - 14) != null) & (Strings.Mid(str11, 15, str11.Length - 14) != ""))) {
            //                    this.ppdecrypter_fileonly = Strings.Mid(str11, 15, str11.Length - 14);
            //                    this.ppdecrypter = Application.StartupPath + @"\_general\tools\" + Strings.Mid(str11, 15, str11.Length - 14);
            //                    if (!File.Exists(this.ppdecrypter)) {
            //                        this.ppdecrypter = "";
            //                        this.ppdecrypter_fileonly = "";
            //                    }
            //                }
            //                if (str11.StartsWith("ppdecrypter_enc_or_dec_lst_files = ")) {
            //                    if (Strings.Mid(str11, 0x24, str11.Length - 0x23) == "D") {
            //                        this.ppdecrypter_enc_or_dec_lst_files = "D";
            //                    }
            //                    else {
            //                        this.ppdecrypter_enc_or_dec_lst_files = "E";
            //                    }
            //                }
            //                if (str11.StartsWith("free_space_warning_MB = ")) {
            //                    this.free_space_warning_MB = Conversions.ToInteger(Strings.Mid(str11, 0x19, str11.Length - 0x18));
            //                }
            //            }
            //            reader.Close();
            //            reader.Dispose();
            //            if ((this.game_regkey != null) & (this.game_regname != null)) {
            //                this.game_path = functions.registry_read(this.game_regkey, this.game_regname);
            //                if ((this.game_path == null) | (this.game_path == "")) {
            //                    this.game_path = functions.registry_read(this.game_regkey_a1, this.game_regname);
            //                }
            //                if ((this.game_path == null) | (this.game_path == "")) {
            //                    this.game_path = functions.registry_read(this.game_regkey_a2, this.game_regname);
            //                }
            //                if ((this.game_path == null) | (this.game_path == "")) {
            //                    this.game_path = functions.registry_read(this.game_regkey_a3, this.game_regname);
            //                }
            //                if (this.game_path == null) {
            //                    this.game_path = "";
            //                }
            //                else {
            //                    if (Strings.Right(this.game_path, 1) != @"\") {
            //                        this.game_path = this.game_path + @"\";
            //                    }
            //                    this.game_ppfilepath = this.game_path + str13 + @"\";
            //                    this.game_lstppfile = this.game_path + str13 + @"\" + str10;
            //                }
            //            }
            //            if ((this.addon1_regkey != null) & (this.addon1_regname != null)) {
            //                this.addon1_path = functions.registry_read(this.addon1_regkey, this.addon1_regname);
            //                if ((this.addon1_path == null) | (this.addon1_path == "")) {
            //                    this.addon1_path = functions.registry_read(this.addon1_regkey_a1, this.game_regname);
            //                }
            //                if ((this.addon1_path == null) | (this.addon1_path == "")) {
            //                    this.addon1_path = functions.registry_read(this.addon1_regkey_a2, this.game_regname);
            //                }
            //                if ((this.addon1_path == null) | (this.addon1_path == "")) {
            //                    this.addon1_path = functions.registry_read(this.addon1_regkey_a3, this.game_regname);
            //                }
            //                if (((this.addon1_path == null) | (this.addon1ID == null)) | (this.addon1ID == "")) {
            //                    this.addon1_path = "";
            //                    this.addon1_ppfilepath = "";
            //                    this.addon1_lstppfile = "";
            //                    this.addon1_active = false;
            //                }
            //                else if (str2 != "") {
            //                    if (str != "") {
            //                        this.addon1_lstppfile = this.addon1_path + str2 + @"\" + str;
            //                    }
            //                    this.addon1_ppfilepath = this.addon1_path + str2 + @"\";
            //                    this.addon1_active = true;
            //                }
            //                else {
            //                    this.addon1_active = false;
            //                }
            //            }
            //            else {
            //                this.addon1_active = false;
            //            }
            //            if ((this.addon2_regkey != null) & (this.addon2_regname != null)) {
            //                this.addon2_path = functions.registry_read(this.addon2_regkey, this.addon2_regname);
            //                if ((this.addon2_path == null) | (this.addon2_path == "")) {
            //                    this.addon2_path = functions.registry_read(this.addon2_regkey_a1, this.game_regname);
            //                }
            //                if ((this.addon2_path == null) | (this.addon2_path == "")) {
            //                    this.addon2_path = functions.registry_read(this.addon2_regkey_a2, this.game_regname);
            //                }
            //                if ((this.addon2_path == null) | (this.addon2_path == "")) {
            //                    this.addon2_path = functions.registry_read(this.addon2_regkey_a3, this.game_regname);
            //                }
            //                if (((this.addon2_path == null) | (this.addon2ID == null)) | (this.addon2ID == "")) {
            //                    this.addon2_path = "";
            //                    this.addon2_ppfilepath = "";
            //                    this.addon2_lstppfile = "";
            //                    this.addon2_active = false;
            //                }
            //                else if (str4 != "") {
            //                    if (str3 != "") {
            //                        str3 = this.addon2_path + str4 + @"\" + str3;
            //                    }
            //                    this.addon2_ppfilepath = this.addon2_path + str4 + @"\";
            //                    this.addon2_active = true;
            //                }
            //                else {
            //                    this.addon2_active = false;
            //                }
            //            }
            //            else {
            //                this.addon2_active = false;
            //            }
            //            if ((this.addon3_regkey != null) & (this.addon3_regname != null)) {
            //                this.addon3_path = functions.registry_read(this.addon3_regkey, this.addon3_regname);
            //                if ((this.addon3_path == null) | (this.addon3_path == "")) {
            //                    this.addon3_path = functions.registry_read(this.addon3_regkey_a1, this.game_regname);
            //                }
            //                if ((this.addon3_path == null) | (this.addon3_path == "")) {
            //                    this.addon3_path = functions.registry_read(this.addon3_regkey_a2, this.game_regname);
            //                }
            //                if ((this.addon3_path == null) | (this.addon3_path == "")) {
            //                    this.addon3_path = functions.registry_read(this.addon3_regkey_a3, this.game_regname);
            //                }
            //                if (((this.addon3_path == null) | (this.addon3ID == null)) | (this.addon3ID == "")) {
            //                    this.addon3_path = "";
            //                    this.addon3_ppfilepath = "";
            //                    this.addon3_lstppfile = "";
            //                    this.addon3_active = false;
            //                }
            //                else if (str6 != "") {
            //                    if (str5 != "") {
            //                        this.addon3_lstppfile = this.addon3_path + str6 + @"\" + str5;
            //                    }
            //                    this.addon3_ppfilepath = this.addon3_path + str6 + @"\";
            //                    this.addon3_active = true;
            //                }
            //                else {
            //                    this.addon3_active = false;
            //                }
            //            }
            //            else {
            //                this.addon3_active = false;
            //            }
            //            if ((this.addon4_regkey != null) & (this.addon4_regname != null)) {
            //                this.addon4_path = functions.registry_read(this.addon4_regkey, this.addon4_regname);
            //                if ((this.addon4_path == null) | (this.addon4_path == "")) {
            //                    this.addon4_path = functions.registry_read(this.addon4_regkey_a1, this.game_regname);
            //                }
            //                if ((this.addon4_path == null) | (this.addon4_path == "")) {
            //                    this.addon4_path = functions.registry_read(this.addon4_regkey_a2, this.game_regname);
            //                }
            //                if ((this.addon4_path == null) | (this.addon4_path == "")) {
            //                    this.addon4_path = functions.registry_read(this.addon4_regkey_a3, this.game_regname);
            //                }
            //                if (((this.addon4_path == null) | (this.addon4ID == null)) | (this.addon4ID == "")) {
            //                    this.addon4_path = "";
            //                    this.addon4_ppfilepath = "";
            //                    this.addon4_lstppfile = "";
            //                    this.addon4_active = false;
            //                }
            //                else if (str8 != "") {
            //                    if (str7 != "") {
            //                        this.addon4_lstppfile = this.addon4_path + str8 + @"\" + str7;
            //                    }
            //                    this.addon4_ppfilepath = this.addon4_path + str8 + @"\";
            //                    this.addon4_active = true;
            //                }
            //                else {
            //                    this.addon4_active = false;
            //                }
            //            }
            //            else {
            //                this.addon4_active = false;
            //            }
            //            if (!Directory.Exists(Application.StartupPath + @"\" + this.gameID)) {
            //                Directory.CreateDirectory(Application.StartupPath + @"\" + this.gameID);
            //            }
            //            this.wizzard_mods_path = Application.StartupPath + @"\" + this.gameID + @"\mods";
            //            if (!Directory.Exists(this.wizzard_mods_path)) {
            //                Directory.CreateDirectory(this.wizzard_mods_path);
            //            }
            //            this.wizzard_previews_path = Application.StartupPath + @"\" + this.gameID + @"\previews";
            //            if (!Directory.Exists(this.wizzard_previews_path)) {
            //                Directory.CreateDirectory(this.wizzard_previews_path);
            //            }
            //            this.wizzard_descriptions_path = Application.StartupPath + @"\" + this.gameID + @"\descriptions";
            //            if (!Directory.Exists(this.wizzard_descriptions_path)) {
            //                Directory.CreateDirectory(this.wizzard_descriptions_path);
            //            }
            //            this.wizzard_backups_path = Application.StartupPath + @"\" + this.gameID + @"\backups";
            //            if (!Directory.Exists(this.wizzard_backups_path)) {
            //                Directory.CreateDirectory(this.wizzard_backups_path);
            //            }
            //            this.wizzard_temp_path = Application.StartupPath + @"\" + this.gameID + @"\temp";
            //            this.wizzard_pp_temp_path = Application.StartupPath + @"\" + this.gameID + @"\temp\pp_temp";
            //            if (this.gameID == "AG3") {
            //                if (!Directory.Exists(Application.StartupPath + @"\AG3\models")) {
            //                    Directory.CreateDirectory(Application.StartupPath + @"\AG3\models");
            //                }
            //                if (!Directory.Exists(Application.StartupPath + @"\AG3\models\body")) {
            //                    Directory.CreateDirectory(Application.StartupPath + @"\AG3\models\body");
            //                }
            //                if (!Directory.Exists(Application.StartupPath + @"\AG3\models\face")) {
            //                    Directory.CreateDirectory(Application.StartupPath + @"\AG3\models\face");
            //                }
            //                if (!Directory.Exists(Application.StartupPath + @"\AG3\models\skin")) {
            //                    Directory.CreateDirectory(Application.StartupPath + @"\AG3\models\skin");
            //                }
            //                if (!Directory.Exists(Application.StartupPath + @"\AG3\models\make_up")) {
            //                    Directory.CreateDirectory(Application.StartupPath + @"\AG3\models\make_up");
            //                }
            //            }
            //            this.wizzard_ini_file = Application.StartupPath + @"\" + this.gameID + @"\illusion_wizzard.ini";
            //            this.wizzard_queue_file = Application.StartupPath + @"\" + this.gameID + @"\queue.txt";
            //            this.window_location_x = 100;
            //            this.window_location_y = 80;
            //            this.window_height = 660;
            //            this.detailed_logging = false;
            //            this.expert_mode = false;
            //            this.picture_switching = true;
            //            this.picture_switch_time = "3";
            //            this.collision_check = Conversions.ToByte("2");
            //            this.game_manual_path = false;
            //            this.addon1_manual_path = false;
            //            this.addon2_manual_path = false;
            //            this.addon3_manual_path = false;
            //            this.addon4_manual_path = false;
            //            this.game_exe = "";
            //            this.addon1_exe = "";
            //            this.addon2_exe = "";
            //            this.addon3_exe = "";
            //            this.addon4_exe = "";
            //            if (File.Exists(this.wizzard_ini_file)) {
            //                StreamReader reader2 = new StreamReader(this.wizzard_ini_file);
            //                while (!reader2.EndOfStream) {
            //                    string str9 = reader2.ReadLine();
            //                    switch (str9) {
            //                        case "expert_mode = 1":
            //                            this.expert_mode = true;
            //                            break;

            //                        case "detailed_logging = 1":
            //                            this.detailed_logging = true;
            //                            break;

            //                        case "picture_switching = 0":
            //                            this.picture_switching = false;
            //                            break;
            //                    }
            //                    if (str9.StartsWith("picture_switch_time = ") && ((Operators.CompareString(Strings.Mid(str9, 0x17, str9.Length - 0x16), "1", false) >= 0) & (Operators.CompareString(Strings.Mid(str9, 0x17, str9.Length - 0x16), "9", false) <= 0))) {
            //                        this.picture_switch_time = Strings.Mid(str9, 0x17, str9.Length - 0x16);
            //                    }
            //                    if (str9.StartsWith("collision_check = ")) {
            //                        if (Strings.Mid(str9, 0x13, str9.Length - 0x12) == "0") {
            //                            this.collision_check = 0;
            //                        }
            //                        else if (Strings.Mid(str9, 0x13, str9.Length - 0x12) == "1") {
            //                            this.collision_check = 1;
            //                        }
            //                        else if (Strings.Mid(str9, 0x13, str9.Length - 0x12) == "2") {
            //                            this.collision_check = 2;
            //                        }
            //                        else if (Strings.Mid(str9, 0x13, str9.Length - 0x12) == "3") {
            //                            this.collision_check = 3;
            //                        }
            //                    }
            //                    if (str9.StartsWith("game_path = ")) {
            //                        this.game_path = Strings.Mid(str9, 13, str9.Length - 12);
            //                        this.game_manual_path = true;
            //                        this.game_ppfilepath = this.game_path + str13 + @"\";
            //                        this.game_lstppfile = this.game_path + str13 + @"\" + str10;
            //                    }
            //                    if (str9.StartsWith("addon1_path = ")) {
            //                        this.addon1_path = Strings.Mid(str9, 15, str9.Length - 14);
            //                        this.addon1_manual_path = true;
            //                        if (((this.addon1_path == null) | (this.addon1ID == null)) | (this.addon1ID == "")) {
            //                            this.addon1_path = "";
            //                            this.addon1_ppfilepath = "";
            //                            this.addon1_lstppfile = "";
            //                            this.addon1_active = false;
            //                        }
            //                        else if (str2 != "") {
            //                            if (str != "") {
            //                                this.addon1_lstppfile = this.addon1_path + str2 + str + @"\";
            //                            }
            //                            this.addon1_ppfilepath = this.addon1_path + str2 + @"\";
            //                            this.addon1_active = true;
            //                        }
            //                        else {
            //                            this.addon1_active = false;
            //                        }
            //                    }
            //                    if (str9.StartsWith("addon2_path = ")) {
            //                        this.addon2_path = Strings.Mid(str9, 15, str9.Length - 14);
            //                        this.addon2_manual_path = true;
            //                        if (((this.addon2_path == null) | (this.addon2ID == null)) | (this.addon2ID == "")) {
            //                            this.addon2_path = "";
            //                            this.addon2_ppfilepath = "";
            //                            this.addon2_lstppfile = "";
            //                            this.addon2_active = false;
            //                        }
            //                        else if (str4 != "") {
            //                            if (str3 != "") {
            //                                this.addon2_lstppfile = this.addon2_path + str4 + str3 + @"\";
            //                            }
            //                            this.addon2_ppfilepath = this.addon2_path + str4 + @"\";
            //                            this.addon2_active = true;
            //                        }
            //                        else {
            //                            this.addon2_active = false;
            //                        }
            //                    }
            //                    if (str9.StartsWith("addon3_path = ")) {
            //                        this.addon3_path = Strings.Mid(str9, 15, str9.Length - 14);
            //                        this.addon3_manual_path = true;
            //                        if (((this.addon3_path == null) | (this.addon3ID == null)) | (this.addon3ID == "")) {
            //                            this.addon3_path = "";
            //                            this.addon3_ppfilepath = "";
            //                            this.addon3_lstppfile = "";
            //                            this.addon3_active = false;
            //                        }
            //                        else if (str6 != "") {
            //                            if (str5 != "") {
            //                                this.addon3_lstppfile = this.addon3_path + str6 + str5 + @"\";
            //                            }
            //                            this.addon3_ppfilepath = this.addon3_path + str6 + @"\";
            //                            this.addon3_active = true;
            //                        }
            //                        else {
            //                            this.addon3_active = false;
            //                        }
            //                    }
            //                    if (str9.StartsWith("addon4_path = ")) {
            //                        this.addon4_path = Strings.Mid(str9, 15, str9.Length - 14);
            //                        this.addon4_manual_path = true;
            //                        if (((this.addon4_path == null) | (this.addon4ID == null)) | (this.addon4ID == "")) {
            //                            this.addon4_path = "";
            //                            this.addon4_ppfilepath = "";
            //                            this.addon4_lstppfile = "";
            //                            this.addon4_active = false;
            //                        }
            //                        else if (str8 != "") {
            //                            if (str7 != "") {
            //                                this.addon4_lstppfile = this.addon4_path + str8 + str7 + @"\";
            //                            }
            //                            this.addon4_ppfilepath = this.addon4_path + str8 + @"\";
            //                            this.addon4_active = true;
            //                        }
            //                        else {
            //                            this.addon4_active = false;
            //                        }
            //                    }
            //                    if (str9.StartsWith("window_height = ")) {
            //                        this.window_height = Conversions.ToInteger(Strings.Mid(str9, 0x11, str9.Length - 0x10));
            //                    }
            //                    if (str9.StartsWith("window_location_x = ") && (Conversions.ToDouble(Strings.Mid(str9, 0x15, str9.Length - 20)) > 0.0)) {
            //                        this.window_location_x = Conversions.ToInteger(Strings.Mid(str9, 0x15, str9.Length - 20));
            //                    }
            //                    if (str9.StartsWith("window_location_y = ") && (Conversions.ToDouble(Strings.Mid(str9, 0x15, str9.Length - 20)) > 0.0)) {
            //                        this.window_location_y = Conversions.ToInteger(Strings.Mid(str9, 0x15, str9.Length - 20));
            //                    }
            //                    if (str9.StartsWith("game_exe = ")) {
            //                        this.game_exe = Strings.Mid(str9, 12, str9.Length - 11);
            //                    }
            //                    if (str9.StartsWith("addon1_exe = ")) {
            //                        this.addon1_exe = Strings.Mid(str9, 14, str9.Length - 13);
            //                    }
            //                    if (str9.StartsWith("addon2_exe = ")) {
            //                        this.addon2_exe = Strings.Mid(str9, 14, str9.Length - 13);
            //                    }
            //                    if (str9.StartsWith("addon3_exe = ")) {
            //                        this.addon3_exe = Strings.Mid(str9, 14, str9.Length - 13);
            //                    }
            //                    if (str9.StartsWith("addon4_exe = ")) {
            //                        this.addon4_exe = Strings.Mid(str9, 14, str9.Length - 13);
            //                    }
            //                }
            //                reader2.Close();
            //                reader2.Dispose();
            //            }
            //            this.unicode_install_dir = false;
            //            if (this.game_path != "") {
            //                int length = this.game_path.Length;
            //                for (num = 1; num <= length; num++) {
            //                    if (Strings.Asc(Strings.Mid(this.game_path, num, 1)) == 0x3f) {
            //                        this.unicode_install_dir = true;
            //                        break;
            //                    }
            //                }
            //            }
            //            if ((this.addon1_path != "") & !this.unicode_install_dir) {
            //                int num3 = this.addon1_path.Length;
            //                for (num = 1; num <= num3; num++) {
            //                    if (Strings.Asc(Strings.Mid(this.addon1_path, num, 1)) == 0x3f) {
            //                        this.unicode_install_dir = true;
            //                        break;
            //                    }
            //                }
            //            }
            //            if (!string.IsNullOrEmpty(this.addon2_path) && !this.unicode_install_dir) {
            //                int num4 = this.addon2_path.Length;
            //                for (num = 1; num <= num4; num++) {
            //                    if (Strings.Asc(Strings.Mid(this.addon2_path, num, 1)) == 0x3f) {
            //                        this.unicode_install_dir = true;
            //                        break;
            //                    }
            //                }
            //            }
            //            if (!string.IsNullOrEmpty(this.addon3_path) && !this.unicode_install_dir) {
            //                for (num = 1; num <= this.addon3_path.Length; num++) {
            //                    if (Strings.Asc(Strings.Mid(this.addon3_path, num, 1)) == 0x3f) {
            //                        this.unicode_install_dir = true;
            //                        break;
            //                    }
            //                }
            //            }
            //            if (!string.IsNullOrEmpty(this.addon4_path) && !this.unicode_install_dir) {
            //                int num6 = this.addon4_path.Length;
            //                for (num = 1; num <= num6; num++) {
            //                    if (Strings.Asc(Strings.Mid(this.addon4_path, num, 1)) == 0x3f) {
            //                        this.unicode_install_dir = true;
            //                        break;
            //                    }
            //                }
            //            }
            //            if (this.free_space_warning_MB == 0) {
            //                this.free_space_warning_MB = 0x400;
            //            }
            //            if ((this.game_path == null) | (this.game_path == "")) {
            //                this.game_drive_free_space_MB = this.free_space_warning_MB;
            //            }
            //            else {
            //                this.game_drive_free_space_MB = cl_utility.get_free_disk_space_in_MB(Strings.Mid(this.game_path, 1, 3));
            //            }
            //            this.wizzard_drive_free_space_MB = cl_utility.get_free_disk_space_in_MB(Strings.Mid(Application.StartupPath, 1, 3));
            //        }
            //    }
            //}



            //public void set_install_and_tools_status() {
            //    if (this.game_manual_path) {
            //        MyProject.Forms.wizzard_main.game_manual_setting.Visible = true;
            //    }
            //    else {
            //        MyProject.Forms.wizzard_main.game_manual_setting.Visible = false;
            //    }
            //    this.global_check_status = 0;
            //    MyProject.Forms.wizzard_main.game_install_status.Image = Image.FromFile(base.graphics_path + @"\red.png");
            //    if (this.game_path != "") {
            //        if (Directory.Exists(this.game_path)) {
            //            if (Directory.Exists(this.game_ppfilepath)) {
            //                if (File.Exists(this.game_lstppfile)) {
            //                    MyProject.Forms.wizzard_main.game_install_dir.Text = this.game_path;
            //                    if (this.game_description != "") {
            //                        MyProject.Forms.wizzard_main.game_install_dir_text.Text = this.game_description;
            //                    }
            //                    MyProject.Forms.wizzard_main.game_install_status.Image = Image.FromFile(base.graphics_path + @"\green.png");
            //                }
            //                else {
            //                    MyProject.Forms.wizzard_main.game_install_dir.Text = "lst pp file: " + this.game_lstppfile + " not found!";
            //                    this.global_check_status = 1;
            //                }
            //            }
            //            else {
            //                MyProject.Forms.wizzard_main.game_install_dir.Text = "pp-file directory: " + this.game_ppfilepath + " not found!";
            //                this.global_check_status = 1;
            //            }
            //        }
            //        else {
            //            MyProject.Forms.wizzard_main.game_install_dir.Text = "Game directory: " + this.game_path + " not found!";
            //            this.global_check_status = 1;
            //        }
            //    }
            //    else {
            //        MyProject.Forms.wizzard_main.game_install_dir.Text = "Not installed or no game path specified!";
            //        this.global_check_status = 1;
            //    }
            //    if (this.addon1_manual_path) {
            //        MyProject.Forms.wizzard_main.addon1_manual_setting.Visible = true;
            //    }
            //    else {
            //        MyProject.Forms.wizzard_main.addon1_manual_setting.Visible = false;
            //    }
            //    if ((this.addon1_path != "") & this.addon1_active) {
            //        MyProject.Forms.wizzard_main.addon1_install_dir.Text = this.addon1_path;
            //        if (this.addon1_description != "") {
            //            MyProject.Forms.wizzard_main.addon1_install_dir_text.Text = this.addon1_description;
            //        }
            //        MyProject.Forms.wizzard_main.addon1_install_status.Image = Image.FromFile(base.graphics_path + @"\green.png");
            //    }
            //    else {
            //        MyProject.Forms.wizzard_main.addon1_install_dir.Text = "addon1 not specifed in parameter file";
            //        MyProject.Forms.wizzard_main.addon1_install_status.Image = Image.FromFile(base.graphics_path + @"\yellow.png");
            //    }
            //    if (this.addon2_manual_path & this.addon2_active) {
            //        MyProject.Forms.wizzard_main.addon2_manual_setting.Visible = true;
            //    }
            //    else {
            //        MyProject.Forms.wizzard_main.addon2_manual_setting.Visible = false;
            //    }
            //    if (this.addon2_path != "") {
            //        MyProject.Forms.wizzard_main.addon2_install_dir.Text = this.addon2_path;
            //        if (this.addon2_description != "") {
            //            MyProject.Forms.wizzard_main.addon2_install_dir_text.Text = this.addon2_description;
            //        }
            //        MyProject.Forms.wizzard_main.addon2_install_status.Image = Image.FromFile(base.graphics_path + @"\green.png");
            //    }
            //    else {
            //        MyProject.Forms.wizzard_main.addon2_install_dir.Text = "addon2 not specifed in parameter file";
            //        MyProject.Forms.wizzard_main.addon2_install_status.Image = Image.FromFile(base.graphics_path + @"\yellow.png");
            //    }
            //    if (this.addon3_manual_path & this.addon3_active) {
            //        MyProject.Forms.wizzard_main.addon3_manual_setting.Visible = true;
            //    }
            //    else {
            //        MyProject.Forms.wizzard_main.addon3_manual_setting.Visible = false;
            //    }
            //    if (this.addon3_path != "") {
            //        MyProject.Forms.wizzard_main.addon3_install_dir.Text = this.addon3_path;
            //        if (this.addon3_description != "") {
            //            MyProject.Forms.wizzard_main.addon3_install_dir_text.Text = this.addon3_description;
            //        }
            //        MyProject.Forms.wizzard_main.addon3_install_status.Image = Image.FromFile(base.graphics_path + @"\green.png");
            //    }
            //    else {
            //        MyProject.Forms.wizzard_main.addon3_install_dir.Text = "addon3 not specifed in parameter file";
            //        MyProject.Forms.wizzard_main.addon3_install_status.Image = Image.FromFile(base.graphics_path + @"\yellow.png");
            //    }
            //    if (this.addon4_manual_path & this.addon4_active) {
            //        MyProject.Forms.wizzard_main.addon4_manual_setting.Visible = true;
            //    }
            //    else {
            //        MyProject.Forms.wizzard_main.addon4_manual_setting.Visible = false;
            //    }
            //    if (this.addon4_path != "") {
            //        MyProject.Forms.wizzard_main.addon4_install_dir.Text = this.addon4_path;
            //        if (this.addon4_description != "") {
            //            MyProject.Forms.wizzard_main.addon4_install_dir_text.Text = this.addon4_description;
            //        }
            //        MyProject.Forms.wizzard_main.addon4_install_status.Image = Image.FromFile(base.graphics_path + @"\green.png");
            //    }
            //    else {
            //        MyProject.Forms.wizzard_main.addon4_install_dir.Text = "addon4 not specifed in parameter file";
            //        MyProject.Forms.wizzard_main.addon4_install_status.Image = Image.FromFile(base.graphics_path + @"\yellow.png");
            //    }
            //    if (File.Exists(this.ppdecrypter)) {
            //        MyProject.Forms.wizzard_main.pp_file_decrypter.Text = this.ppdecrypter_fileonly;
            //        MyProject.Forms.wizzard_main.ppdecrypter_status.Image = Image.FromFile(base.graphics_path + @"\green.png");
            //    }
            //    else {
            //        MyProject.Forms.wizzard_main.pp_file_decrypter.Text = this.ppdecrypter_fileonly + " not found!";
            //        MyProject.Forms.wizzard_main.ppdecrypter_status.Image = Image.FromFile(base.graphics_path + @"\red.png");
            //        this.global_check_status += 2;
            //    }
            //    if (File.Exists(base.sevenz_exe)) {
            //        MyProject.Forms.wizzard_main.sevenz_status.Image = Image.FromFile(base.graphics_path + @"\green.png");
            //    }
            //    else {
            //        MyProject.Forms.wizzard_main.sevenz_status.Image = Image.FromFile(base.graphics_path + @"\red.png");
            //        this.global_check_status += 4;
            //    }
            //    if (File.Exists(base.contig_exe)) {
            //        MyProject.Forms.wizzard_main.contig_status.Image = Image.FromFile(base.graphics_path + @"\green.png");
            //    }
            //    else {
            //        MyProject.Forms.wizzard_main.contig_status.Image = Image.FromFile(base.graphics_path + @"\red.png");
            //    }
            //}

            //public void set_options() {
            //    if (!this.allow_collision_check) {
            //        MyProject.Forms.wizzard_main.collision_check_ask.Checked = false;
            //        MyProject.Forms.wizzard_main.collision_check_ask.Visible = false;
            //        MyProject.Forms.wizzard_main.collision_check_auto1.Checked = false;
            //        MyProject.Forms.wizzard_main.collision_check_auto1.Visible = false;
            //        MyProject.Forms.wizzard_main.collision_check_auto2.Checked = false;
            //        MyProject.Forms.wizzard_main.collision_check_auto2.Visible = false;
            //        MyProject.Forms.wizzard_main.collision_check_off.Checked = true;
            //    }
            //    else if (this.collision_check == Conversions.ToDouble("0")) {
            //        MyProject.Forms.wizzard_main.collision_check_ask.Checked = false;
            //        MyProject.Forms.wizzard_main.collision_check_auto1.Checked = false;
            //        MyProject.Forms.wizzard_main.collision_check_auto1.Checked = false;
            //        MyProject.Forms.wizzard_main.collision_check_off.Checked = true;
            //    }
            //    else if (this.collision_check == Conversions.ToDouble("1")) {
            //        MyProject.Forms.wizzard_main.collision_check_ask.Checked = false;
            //        MyProject.Forms.wizzard_main.collision_check_auto1.Checked = true;
            //        MyProject.Forms.wizzard_main.collision_check_auto2.Checked = false;
            //        MyProject.Forms.wizzard_main.collision_check_off.Checked = false;
            //    }
            //    else if (this.collision_check == Conversions.ToDouble("2")) {
            //        MyProject.Forms.wizzard_main.collision_check_ask.Checked = false;
            //        MyProject.Forms.wizzard_main.collision_check_auto1.Checked = false;
            //        MyProject.Forms.wizzard_main.collision_check_auto2.Checked = true;
            //        MyProject.Forms.wizzard_main.collision_check_off.Checked = false;
            //    }
            //    else {
            //        MyProject.Forms.wizzard_main.collision_check_ask.Checked = true;
            //        MyProject.Forms.wizzard_main.collision_check_auto1.Checked = false;
            //        MyProject.Forms.wizzard_main.collision_check_auto2.Checked = false;
            //        MyProject.Forms.wizzard_main.collision_check_off.Checked = false;
            //    }
            //    MyProject.Forms.wizzard_main.picture_switch_time.Text = this.picture_switch_time;
            //    if (this.expert_mode) {
            //        MyProject.Forms.wizzard_main.expert_mode.CheckState = CheckState.Checked;
            //    }
            //    else {
            //        MyProject.Forms.wizzard_main.expert_mode.CheckState = CheckState.Unchecked;
            //    }
            //    if (this.picture_switching) {
            //        MyProject.Forms.wizzard_main.picture_switch_off.CheckState = CheckState.Unchecked;
            //        MyProject.Forms.wizzard_main.picture_change_timer.Enabled = true;
            //    }
            //    else {
            //        MyProject.Forms.wizzard_main.picture_switch_off.CheckState = CheckState.Checked;
            //        MyProject.Forms.wizzard_main.picture_change_timer.Enabled = false;
            //    }
            //    MyProject.Forms.wizzard_main.specify_game_manual_folder.Text = "specify " + this.gameID + " folder manually";
            //    if (this.addon1_active) {
            //        MyProject.Forms.wizzard_main.specify_addon1_manual_folder.Text = "specify " + this.addon1ID + " folder manually";
            //    }
            //    if (this.addon2_active) {
            //        MyProject.Forms.wizzard_main.specify_addon2_manual_folder.Text = "specify " + this.addon2ID + " folder manually";
            //    }
            //    if (this.addon3_active) {
            //        MyProject.Forms.wizzard_main.specify_addon3_manual_folder.Text = "specify " + this.addon3ID + " folder manually";
            //    }
            //    if (this.addon4_active) {
            //        MyProject.Forms.wizzard_main.specify_addon4_manual_folder.Text = "specify " + this.addon4ID + " folder manually";
            //    }
            //    MyProject.Forms.wizzard_main.specify_game_exe.Text = "specify " + this.gameID + " exe";
            //    if (this.addon1_active) {
            //        MyProject.Forms.wizzard_main.specify_addon1_exe.Text = "specify " + this.addon1ID + " exe";
            //    }
            //    if (this.addon2_active) {
            //        MyProject.Forms.wizzard_main.specify_addon2_exe.Text = "specify " + this.addon2ID + " exe";
            //    }
            //    if (this.addon3_active) {
            //        MyProject.Forms.wizzard_main.specify_addon3_exe.Text = "specify " + this.addon3ID + " exe";
            //    }
            //    if (this.addon4_active) {
            //        MyProject.Forms.wizzard_main.specify_addon4_exe.Text = "specify " + this.addon4ID + " exe";
            //    }
            //    MyProject.Forms.wizzard_main.launch_game.Text = this.gameID;
            //    if (this.addon1_active) {
            //        MyProject.Forms.wizzard_main.launch_addon1.Text = this.addon1ID;
            //    }
            //    if (this.addon2_active) {
            //        MyProject.Forms.wizzard_main.launch_addon2.Text = this.addon2ID;
            //    }
            //    if (this.addon3_active) {
            //        MyProject.Forms.wizzard_main.launch_addon3.Text = this.addon3ID;
            //    }
            //    if (this.addon4_active) {
            //        MyProject.Forms.wizzard_main.launch_addon4.Text = this.addon4ID;
            //    }
            //    MyProject.Forms.wizzard_main.game_title.Text = this.game_description;
            //    if (this.game_exe != "") {
            //        MyProject.Forms.wizzard_main.game_exe.Text = this.game_exe;
            //    }
            //    if (this.addon1_exe != "") {
            //        MyProject.Forms.wizzard_main.addon1_exe.Text = this.addon1_exe;
            //    }
            //    if (this.addon2_exe != "") {
            //        MyProject.Forms.wizzard_main.addon2_exe.Text = this.addon2_exe;
            //    }
            //    if (this.addon3_exe != "") {
            //        MyProject.Forms.wizzard_main.addon3_exe.Text = this.addon3_exe;
            //    }
            //    if (this.addon4_exe != "") {
            //        MyProject.Forms.wizzard_main.addon4_exe.Text = this.addon4_exe;
            //    }
            //    if (this.game_manual_path) {
            //        MyProject.Forms.wizzard_main.specify_game_manual_folder.CheckState = CheckState.Checked;
            //        MyProject.Forms.wizzard_main.game_manual_folder.Text = this.game_path;
            //    }
            //    else {
            //        MyProject.Forms.wizzard_main.specify_game_manual_folder.CheckState = CheckState.Unchecked;
            //        MyProject.Forms.wizzard_main.game_manual_folder.Text = "not specified";
            //    }
            //    if (this.addon1_manual_path) {
            //        MyProject.Forms.wizzard_main.specify_addon1_manual_folder.CheckState = CheckState.Checked;
            //        MyProject.Forms.wizzard_main.addon1_manual_folder.Text = this.addon1_path;
            //    }
            //    else {
            //        MyProject.Forms.wizzard_main.specify_addon1_manual_folder.CheckState = CheckState.Unchecked;
            //        MyProject.Forms.wizzard_main.specify_addon1_manual_folder.Text = "not specified";
            //    }
            //    if (this.addon2_manual_path) {
            //        MyProject.Forms.wizzard_main.specify_addon2_manual_folder.CheckState = CheckState.Checked;
            //        MyProject.Forms.wizzard_main.addon2_manual_folder.Text = this.addon2_path;
            //    }
            //    else {
            //        MyProject.Forms.wizzard_main.specify_addon2_manual_folder.CheckState = CheckState.Unchecked;
            //        MyProject.Forms.wizzard_main.specify_addon2_manual_folder.Text = "not specified";
            //    }
            //    if (this.addon3_manual_path) {
            //        MyProject.Forms.wizzard_main.specify_addon3_manual_folder.CheckState = CheckState.Checked;
            //        MyProject.Forms.wizzard_main.addon3_manual_folder.Text = this.addon3_path;
            //    }
            //    else {
            //        MyProject.Forms.wizzard_main.specify_addon3_manual_folder.CheckState = CheckState.Unchecked;
            //        MyProject.Forms.wizzard_main.specify_addon3_manual_folder.Text = "not specified";
            //    }
            //    if (this.addon4_manual_path) {
            //        MyProject.Forms.wizzard_main.specify_addon4_manual_folder.CheckState = CheckState.Checked;
            //        MyProject.Forms.wizzard_main.addon4_manual_folder.Text = this.addon4_path;
            //    }
            //    else {
            //        MyProject.Forms.wizzard_main.specify_addon4_manual_folder.CheckState = CheckState.Unchecked;
            //        MyProject.Forms.wizzard_main.specify_addon4_manual_folder.Text = "not specified";
            //    }
            //    if (base.defrag_files & File.Exists(base.contig_exe)) {
            //        MyProject.Forms.wizzard_main.use_contig.Checked = true;
            //    }
            //    else {
            //        MyProject.Forms.wizzard_main.use_contig.Checked = false;
            //    }
            //}

            //public void set_window_size_and_pos() {
            //    MyProject.Forms.wizzard_main.Height = this.window_height;
            //    Point point = new Point(this.window_location_x, this.window_location_y);
            //    MyProject.Forms.wizzard_main.Location = point;
            //}

            public void write_debug_file() {
            }

            //public void write_ini_file() {
            //    if (File.Exists(this.wizzard_ini_file)) {
            //        FileSystem.Kill(this.wizzard_ini_file);
            //    }
            //    StreamWriter writer = new StreamWriter(this.wizzard_ini_file);
            //    writer.WriteLine("[manual game path information]");
            //    if (MyProject.Forms.wizzard_main.specify_game_manual_folder.CheckState == CheckState.Checked) {
            //        writer.WriteLine("game_path = " + MyProject.Forms.wizzard_main.game_manual_folder.Text);
            //    }
            //    if (MyProject.Forms.wizzard_main.specify_addon1_manual_folder.CheckState == CheckState.Checked) {
            //        writer.WriteLine("addon1_path = " + MyProject.Forms.wizzard_main.addon1_manual_folder.Text);
            //    }
            //    if (MyProject.Forms.wizzard_main.specify_addon2_manual_folder.CheckState == CheckState.Checked) {
            //        writer.WriteLine("addon2_path = " + MyProject.Forms.wizzard_main.addon2_manual_folder.Text);
            //    }
            //    if (MyProject.Forms.wizzard_main.specify_addon3_manual_folder.CheckState == CheckState.Checked) {
            //        writer.WriteLine("addon3_path = " + MyProject.Forms.wizzard_main.addon3_manual_folder.Text);
            //    }
            //    if (MyProject.Forms.wizzard_main.specify_addon4_manual_folder.CheckState == CheckState.Checked) {
            //        writer.WriteLine("addon4_path = " + MyProject.Forms.wizzard_main.addon4_manual_folder.Text);
            //    }
            //    writer.WriteLine("");
            //    writer.WriteLine("[game launch information]");
            //    if (MyProject.Forms.wizzard_main.game_exe.Text != "not specified") {
            //        writer.WriteLine("game_exe = " + MyProject.Forms.wizzard_main.game_exe.Text);
            //    }
            //    if (MyProject.Forms.wizzard_main.addon1_exe.Text != "not specified") {
            //        writer.WriteLine("addon1_exe = " + MyProject.Forms.wizzard_main.addon1_exe.Text);
            //    }
            //    if (MyProject.Forms.wizzard_main.addon2_exe.Text != "not specified") {
            //        writer.WriteLine("addon2_exe = " + MyProject.Forms.wizzard_main.addon2_exe.Text);
            //    }
            //    if (MyProject.Forms.wizzard_main.addon3_exe.Text != "not specified") {
            //        writer.WriteLine("addon3_exe = " + MyProject.Forms.wizzard_main.addon3_exe.Text);
            //    }
            //    if (MyProject.Forms.wizzard_main.addon4_exe.Text != "not specified") {
            //        writer.WriteLine("addon4_exe = " + MyProject.Forms.wizzard_main.addon4_exe.Text);
            //    }
            //    writer.WriteLine("");
            //    writer.WriteLine("[illusion wizzard misc settings]");
            //    writer.WriteLine("detailed_logging = " + Conversions.ToString((int)MyProject.Forms.wizzard_main.detailed_logging.CheckState));
            //    writer.WriteLine("expert_mode = " + Conversions.ToString((int)MyProject.Forms.wizzard_main.expert_mode.CheckState));
            //    if (MyProject.Forms.wizzard_main.picture_switch_off.CheckState == CheckState.Checked) {
            //        writer.WriteLine("picture_switching = 0");
            //    }
            //    else {
            //        writer.WriteLine("picture_switching = 1");
            //    }
            //    writer.WriteLine("picture_switch_time = " + MyProject.Forms.wizzard_main.picture_switch_time.Text);
            //    if (MyProject.Forms.wizzard_main.collision_check_auto2.Checked) {
            //        writer.WriteLine("collision_check = 2");
            //    }
            //    else if (MyProject.Forms.wizzard_main.collision_check_auto1.Checked) {
            //        writer.WriteLine("collision_check = 1");
            //    }
            //    else if (MyProject.Forms.wizzard_main.collision_check_off.Checked) {
            //        writer.WriteLine("collision_check = 0");
            //    }
            //    else {
            //        writer.WriteLine("collision_check = 3");
            //    }
            //    writer.WriteLine("");
            //    writer.WriteLine("[window settings]");
            //    writer.WriteLine("window_height = " + Conversions.ToString(MyProject.Forms.wizzard_main.Size.Height));
            //    writer.WriteLine("window_location_x = " + Conversions.ToString(MyProject.Forms.wizzard_main.Location.X));
            //    writer.WriteLine("window_location_y = " + Conversions.ToString(MyProject.Forms.wizzard_main.Location.Y));
            //    writer.Close();
            //    string path = null;
            //    path = Application.StartupPath + @"\illusion_wizzard.ini";
            //    if (File.Exists(path)) {
            //        FileSystem.Kill(path);
            //    }
            //    writer = new StreamWriter(path);
            //    writer.WriteLine("[Default / last used GameID]");
            //    if ((MyProject.Forms.wizzard_main.games_list.SelectedItem != null) & MyProject.Forms.wizzard_main.games_list.Items.Contains(MyProject.Forms.wizzard_main.games_list.Text)) {
            //        writer.WriteLine(Operators.ConcatenateObject("default_GameID = ", MyProject.Forms.wizzard_main.games_list.SelectedItem));
            //    }
            //    if (MyProject.Forms.wizzard_main.Skip_game_selector.Checked) {
            //        writer.WriteLine("skip_first_screen = 1");
            //    }
            //    else {
            //        writer.WriteLine("skip_first_screen = 0");
            //    }
            //    if (MyProject.Forms.wizzard_main.use_contig.Checked) {
            //        writer.WriteLine("defrag_files = 1");
            //    }
            //    else {
            //        writer.WriteLine("defrag_files = 0");
            //    }
            //    writer.Close();
            //}

            //public void write_window_size_and_pos() {
            //    int num = 0;
            //    string[] strArray = null;
            //    int num2 = 0;
            //    strArray = new string[0x1f5];
            //    if (File.Exists(this.wizzard_ini_file)) {
            //        StreamReader reader = new StreamReader(this.wizzard_ini_file);
            //        for (num = 0; !reader.EndOfStream; num++) {
            //            num2 = num;
            //            strArray.SetValue(reader.ReadLine(), num);
            //        }
            //        reader.Close();
            //        FileSystem.Kill(this.wizzard_ini_file);
            //    }
            //    StreamWriter writer = new StreamWriter(this.wizzard_ini_file, false);
            //    int num3 = num2;
            //    for (num = 0; num <= num3; num++) {
            //        if ((((Strings.Mid(strArray[num], 1, 0x10) != "window_height = ") & (Strings.Mid(strArray[num], 1, 20) != "window_location_x = ")) & (Strings.Mid(strArray[num], 1, 20) != "window_location_y = ")) & (Strings.Mid(strArray[num], 1, 0x11) != "[window settings]")) {
            //            writer.WriteLine(strArray[num]);
            //        }
            //    }
            //    writer.WriteLine("[window settings]");
            //    writer.WriteLine("window_height = " + Conversions.ToString(MyProject.Forms.wizzard_main.Size.Height));
            //    writer.WriteLine("window_location_x = " + Conversions.ToString(MyProject.Forms.wizzard_main.Location.X));
            //    writer.WriteLine("window_location_y = " + Conversions.ToString(MyProject.Forms.wizzard_main.Location.Y));
            //    writer.Close();
            //}
        }

        public class cl_global_wizzard_data {
            public string contig_exe;
            public bool defrag_files;
            public bool first_time_loading = true;
            public string game_profiles_path;
            public string graphics_path;
            public string language_files_path;
            public string sevenz_exe;
            public string tools_path;

            public void get_wizzard_data() {
                this.graphics_path = Application.StartupPath + @"\_general\graphics";
                if (!Directory.Exists(this.graphics_path)) {
                    this.graphics_path = "";
                }
                this.tools_path = Application.StartupPath + @"\_general\tools";
                if (!Directory.Exists(this.tools_path)) {
                    this.tools_path = "";
                }
                this.sevenz_exe = Application.StartupPath + @"\_general\tools\7zip.exe";
                if (!File.Exists(this.sevenz_exe)) {
                    this.sevenz_exe = "";
                }
                this.contig_exe = Application.StartupPath + @"\_general\tools\contig.exe";
                if (!File.Exists(this.contig_exe)) {
                    this.contig_exe = "";
                }
                this.language_files_path = Application.StartupPath + @"\_general\language_files";
                if (!Directory.Exists(this.language_files_path)) {
                    this.language_files_path = "";
                }
                this.game_profiles_path = Application.StartupPath + @"\_general\game_profiles";
                if (!Directory.Exists(this.game_profiles_path)) {
                    this.game_profiles_path = "";
                }
                string path = null;
                path = Application.StartupPath + @"\illusion_wizzard.ini";
                this.defrag_files = false;
                if (File.Exists(path)) {
                    StreamReader reader = new StreamReader(path);
                    while (!reader.EndOfStream) {
                        if (reader.ReadLine().StartsWith("defrag_files = 1") & File.Exists(this.contig_exe)) {
                            this.defrag_files = true;
                        }
                    }
                    reader.Close();
                }
            }
        }

        public class cl_lst_modfile_integrator {
            public bool create_undofile = true;
            public string lst_directory;
            public string lst_modfile;
            public string lst_undofile = "";

            public void decode_lst_files() {
                byte[] buffer = new byte[0x20];
                DirectoryInfo info = new DirectoryInfo(this.lst_directory);
                foreach (FileInfo info2 in info.GetFiles("*.lst")) {
                    FileStream input = new FileStream(info2.FullName, FileMode.Open, FileAccess.Read);
                    BinaryReader reader = new BinaryReader(input);
                    ulong num4 = 0x227d3072a26c426bL;
                    if (num4 != reader.ReadUInt64()) {
                        reader.Close();
                        input.Close();
                        input.Dispose();
                    }
                    else {
                        byte[] buffer3 = new byte[((int)(reader.BaseStream.Length - 1L)) + 1];
                        reader.BaseStream.Position = 0L;
                        reader.BaseStream.Read(buffer3, 0, (int)reader.BaseStream.Length);
                        buffer[3] = 0x5e;
                        buffer[2] = 0xe0;
                        buffer[1] = 0x35;
                        buffer[0] = 0x2d;
                        buffer[7] = 0x57;
                        buffer[6] = 12;
                        buffer[5] = 0x1d;
                        buffer[4] = 0x26;
                        buffer[11] = 0x48;
                        buffer[10] = 0x7f;
                        buffer[9] = 0x2e;
                        buffer[8] = 0x1d;
                        buffer[15] = 0x85;
                        buffer[14] = 80;
                        buffer[13] = 0xb6;
                        buffer[12] = 0x2e;
                        buffer[0x13] = 0x9a;
                        buffer[0x12] = 0xbf;
                        buffer[0x11] = 0xfc;
                        buffer[0x10] = 0xb7;
                        buffer[0x17] = 0x18;
                        buffer[0x16] = 0x44;
                        buffer[0x15] = 0x83;
                        buffer[20] = 0xf5;
                        buffer[0x1b] = 0x4b;
                        buffer[0x1a] = 0x3b;
                        buffer[0x19] = 0xbd;
                        buffer[0x18] = 0xdb;
                        buffer[0x1f] = 0xe3;
                        buffer[30] = 0x57;
                        buffer[0x1d] = 0x92;
                        buffer[0x1c] = 0xff;
                        int num3 = buffer3.Length % 4;
                        byte[] buffer2 = new byte[(buffer3.Length - 9) + 1];
                        int index = 0;
                        int num = 8;
                        while (num < buffer3.Length) {
                            if (num < (buffer3.Length - num3)) {
                                buffer2[num - 8] = (byte)(buffer3[num] ^ buffer[index]);
                                index++;
                            }
                            else {
                                buffer2[num - 8] = buffer3[num];
                            }
                            num++;
                            if (index == 0x20) {
                                index = 0;
                            }
                        }
                        reader.Close();
                        input.Close();
                        input.Dispose();
                        FileStream output = new FileStream(info2.FullName, FileMode.Create, FileAccess.Write);
                        BinaryWriter writer = new BinaryWriter(output);
                        writer.Write(buffer2);
                        writer.Close();
                        output.Close();
                        output.Dispose();
                    }
                }
            }

            public void encode_lst_files() {
                byte[] buffer = new byte[0x20];
                byte[] buffer2 = new byte[8];
                DirectoryInfo info = new DirectoryInfo(this.lst_directory);
                foreach (FileInfo info2 in info.GetFiles("*.lst")) {
                    FileStream input = new FileStream(info2.FullName, FileMode.Open, FileAccess.Read);
                    BinaryReader reader = new BinaryReader(input);
                    ulong num4 = 0x227d3072a26c426bL;
                    if (num4 == reader.ReadUInt64()) {
                        reader.Close();
                        input.Close();
                        input.Dispose();
                    }
                    else {
                        byte[] buffer3 = new byte[((int)(reader.BaseStream.Length - 1L)) + 1];
                        reader.BaseStream.Position = 0L;
                        reader.BaseStream.Read(buffer3, 0, (int)reader.BaseStream.Length);
                        buffer2[0] = 0x6b;
                        buffer2[1] = 0x42;
                        buffer2[2] = 0x6c;
                        buffer2[3] = 0xa2;
                        buffer2[4] = 0x72;
                        buffer2[5] = 0x30;
                        buffer2[6] = 0x7d;
                        buffer2[7] = 0x22;
                        buffer[3] = 0x5e;
                        buffer[2] = 0xe0;
                        buffer[1] = 0x35;
                        buffer[0] = 0x2d;
                        buffer[7] = 0x57;
                        buffer[6] = 12;
                        buffer[5] = 0x1d;
                        buffer[4] = 0x26;
                        buffer[11] = 0x48;
                        buffer[10] = 0x7f;
                        buffer[9] = 0x2e;
                        buffer[8] = 0x1d;
                        buffer[15] = 0x85;
                        buffer[14] = 80;
                        buffer[13] = 0xb6;
                        buffer[12] = 0x2e;
                        buffer[0x13] = 0x9a;
                        buffer[0x12] = 0xbf;
                        buffer[0x11] = 0xfc;
                        buffer[0x10] = 0xb7;
                        buffer[0x17] = 0x18;
                        buffer[0x16] = 0x44;
                        buffer[0x15] = 0x83;
                        buffer[20] = 0xf5;
                        buffer[0x1b] = 0x4b;
                        buffer[0x1a] = 0x3b;
                        buffer[0x19] = 0xbd;
                        buffer[0x18] = 0xdb;
                        buffer[0x1f] = 0xe3;
                        buffer[30] = 0x57;
                        buffer[0x1d] = 0x92;
                        buffer[0x1c] = 0xff;
                        int num3 = buffer3.Length % 4;
                        byte[] buffer4 = new byte[(buffer3.Length + 7) + 1];
                        int index = 0;
                        for (int i = 0; i < (buffer3.Length + 8); i++) {
                            if (i < 8) {
                                buffer4[i] = buffer2[i];
                            }
                            else {
                                if (i < ((buffer3.Length + 8) - num3)) {
                                    buffer4[i] = (byte)(buffer3[i - 8] ^ buffer[index]);
                                }
                                else {
                                    buffer4[i] = buffer3[i - 8];
                                }
                                index++;
                                if (index == 0x20) {
                                    index = 0;
                                }
                            }
                        }
                        reader.Close();
                        input.Close();
                        input.Dispose();
                        FileStream output = new FileStream(info2.FullName, FileMode.Create, FileAccess.Write);
                        BinaryWriter writer = new BinaryWriter(output);
                        writer.Write(buffer4);
                        writer.Close();
                        output.Close();
                        output.Dispose();
                    }
                }
            }

            public void integrate_lst_modfile() {
                string[] strArray3 = new string[0x3e9];
                string[] strArray = new string[0x3e9];
                string[,] strArray4 = new string[2, 0x65];
                string[,] strArray2 = new string[2, 0x65];
                char[] separator = new char[2];
                if (!((this.lst_modfile == null) | !File.Exists(this.lst_modfile))) {
                    int num = 0;
                    int num2 = 0;
                    int num7 = 0;
                    string str4;
                    FileStream stream = new FileStream(this.lst_modfile, FileMode.Open, FileAccess.Read);
                    StreamReader reader = new StreamReader(stream, true);
                    int index = 0;
                    while (!reader.EndOfStream) {
                        strArray3[index] = reader.ReadLine();
                        index++;
                    }
                    reader.Close();
                    stream.Close();
                    int num9 = index - 1;
                    strArray3 = (string[])Utils.CopyArray((Array)strArray3, new string[num9 + 1]);
                    strArray4 = new string[num9 + 1, 0x65];
                    index = 0;
                    while (index <= num9) {
                        num2 = 0;
                        str4 = "";
                        int length = strArray3[index].Length;
                        num = 1;
                        while (num <= length) {
                            if (Strings.Asc(Strings.Mid(strArray3[index], num, 1)) == 9) {
                                strArray4[index, num2] = str4;
                                num2++;
                                str4 = "";
                            }
                            else {
                                str4 = str4 + Strings.Mid(strArray3[index], num, 1);
                            }
                            num++;
                        }
                        if (num7 < num2) {
                            num7 = num2;
                        }
                        strArray4[index, num2] = str4;
                        index++;
                    }
                    strArray4 = (string[,])Utils.CopyArray((Array)strArray4, new string[num9 + 1, num7 + 1]);
                    int num3 = 0;
                    while (num3 <= num9) {
                        string path = this.lst_directory + @"\" + strArray4[num3, 0];
                        int num5 = Conversions.ToInteger(strArray4[num3, 1]);
                        int num11 = (int)Math.Round((double)(Conversions.ToDouble(strArray4[num3, 2]) - 3.0));
                        if (!File.Exists(path)) {
                            break;
                        }
                        FileStream input = new FileStream(path, FileMode.Open, FileAccess.Read);
                        BinaryReader reader2 = new BinaryReader(input);
                        byte[] bytes = new byte[((int)reader2.BaseStream.Length) + 1];
                        reader2.BaseStream.Read(bytes, 0, (int)reader2.BaseStream.Length);
                        string str5 = Encoding.Default.GetString(bytes);
                        separator[0] = '\n';
                        separator[1] = '\r';
                        strArray = str5.Split(separator, 0x989680, StringSplitOptions.RemoveEmptyEntries);
                        reader2.Close();
                        input.Close();
                        int num10 = strArray.GetUpperBound(0) - 1;
                        strArray = (string[])Utils.CopyArray((Array)strArray, new string[num10 + 1]);
                        strArray2 = new string[num10 + 1, 0x1f5];
                        index = 0;
                        int num8 = 0;
                        while (index <= num10) {
                            num2 = 0;
                            str4 = "";
                            int num13 = strArray[index].Length;
                            for (num = 1; num <= num13; num++) {
                                if (Strings.Asc(Strings.Mid(strArray[index], num, 1)) == 9) {
                                    strArray2[index, num2] = str4;
                                    num2++;
                                    str4 = "";
                                }
                                else {
                                    str4 = str4 + Strings.Mid(strArray[index], num, 1);
                                }
                            }
                            if (num8 < num2) {
                                num8 = num2;
                            }
                            strArray2[index, num2] = str4;
                            index++;
                        }
                        strArray2 = (string[,])Utils.CopyArray((Array)strArray2, new string[num10 + 1, num8 + 1]);
                        string str3 = strArray4[num3, 0] + "\t" + strArray4[num3, 1] + "\t" + strArray4[num3, 2];
                        int num6 = Math.Min(num8 - num11, num7);
                        int num14 = num6;
                        num2 = 3;
                        while (num2 <= num14) {
                            str3 = str3 + "\t" + strArray2[num5, num2 + num11];
                            if ((strArray4[num3, num2] != null) & (strArray4[num3, num2] != "")) {
                                strArray2[num5, num2 + num11] = strArray4[num3, num2];
                            }
                            num2++;
                        }
                        if (this.create_undofile & (str3 != (strArray4[num3, 0] + "\t" + strArray4[num3, 1] + "\t" + strArray4[num3, 2]))) {
                            this.write_undofile(str3);
                        }
                        strArray = new string[num10 + 1];
                        index = 0;
                        string s = null;
                        while (index <= num10) {
                            for (num2 = 0; num2 <= num8; num2++) {
                                if (num2 < num8) {
                                    strArray[index] = strArray[index] + strArray2[index, num2] + "\t";
                                }
                                else {
                                    strArray[index] = strArray[index] + strArray2[index, num2];
                                }
                            }
                            s = s + strArray[index] + "\r\n";
                            index++;
                        }
                        FileStream output = new FileStream(path, FileMode.Create, FileAccess.Write);
                        BinaryWriter writer = new BinaryWriter(output);
                        bytes = Encoding.Default.GetBytes(s);
                        writer.BaseStream.Write(bytes, 0, bytes.Length);
                        writer.Close();
                        output.Close();
                        output.Dispose();
                        num3++;
                        strArray = new string[0x3e9];
                        strArray2 = new string[2, 0x65];
                    }
                }
            }

            private void write_undofile(string lst_undoline) {
                StreamWriter writer = new StreamWriter(this.lst_undofile, true);
                writer.WriteLine(lst_undoline);
                writer.Close();
            }
        }

        //public class cl_sevenzip {
        //    public bool display_description_txt = false;
        //    public bool display_preview_pic = false;
        //    public string filename_pic;
        //    public classes.cl_global_game_data global_data = new classes.cl_global_game_data();
        //    public string installed_mod_sevenz_filename;
        //    public string mod_or_installed_or_queue = "M";
        //    public string mod_sevenz_filename;
        //    public string queue_sevenz_filename;
        //    public string undo_path;

        //    public void extract_preview_pic() {
        //        string str;
        //        string str2;
        //        string str3;
        //        if (this.mod_or_installed_or_queue == "M") {
        //            if (this.mod_sevenz_filename == null) {
        //                MyProject.Forms.wizzard_main.preview_pic.Image = null;
        //                this.filename_pic = null;
        //                this.undo_path = this.global_data.wizzard_temp_path;
        //                return;
        //            }
        //            str2 = this.global_data.wizzard_mods_path;
        //            str3 = this.mod_sevenz_filename;
        //        }
        //        else if (this.mod_or_installed_or_queue == "I") {
        //            if (this.installed_mod_sevenz_filename == null) {
        //                MyProject.Forms.wizzard_main.preview_pic.Image = null;
        //                this.filename_pic = null;
        //                this.undo_path = this.global_data.wizzard_temp_path;
        //                return;
        //            }
        //            str2 = this.global_data.wizzard_backups_path;
        //            str3 = this.installed_mod_sevenz_filename;
        //        }
        //        else {
        //            if (this.queue_sevenz_filename == null) {
        //                MyProject.Forms.wizzard_main.preview_pic.Image = null;
        //                this.filename_pic = null;
        //                this.undo_path = this.global_data.wizzard_temp_path;
        //                return;
        //            }
        //            str2 = this.global_data.wizzard_mods_path;
        //            str3 = this.queue_sevenz_filename;
        //        }
        //        if (str3.EndsWith(".7z")) {
        //            str = str3.Remove(str3.Length - 3, 3);
        //        }
        //        else {
        //            if (!(str3.EndsWith(".rar") | str3.EndsWith(".zip"))) {
        //                return;
        //            }
        //            str = str3.Remove(str3.Length - 4, 4);
        //        }
        //        this.filename_pic = str + ".jpg";
        //        if (!File.Exists(this.global_data.wizzard_previews_path + @"\" + this.filename_pic) & !File.Exists(this.global_data.wizzard_previews_path + @"\" + str + "1.jpg")) {
        //            Interaction.Shell(this.global_data.sevenz_exe + " e \"" + str2 + @"\" + str3 + "\" -aoa \"-o" + this.global_data.wizzard_previews_path + "\\\" *.jpg", AppWinStyle.MinimizedFocus, true, -1);
        //        }
        //        if (this.display_preview_pic) {
        //            if (File.Exists(this.global_data.wizzard_previews_path + @"\" + this.filename_pic)) {
        //                MyProject.Forms.wizzard_main.preview_pic.Image = Image.FromFile(this.global_data.wizzard_previews_path + @"\" + this.filename_pic);
        //            }
        //            else if (File.Exists(this.global_data.wizzard_previews_path + @"\" + str + "1.jpg")) {
        //                MyProject.Forms.wizzard_main.preview_pic.Image = Image.FromFile(this.global_data.wizzard_previews_path + @"\" + str + "1.jpg");
        //            }
        //            else {
        //                MyProject.Forms.wizzard_main.preview_pic.Image = Image.FromFile(this.global_data.graphics_path + @"\no_preview.jpg");
        //            }
        //        }
        //        this.undo_path = this.global_data.wizzard_temp_path + @"\" + str;
        //    }

        //    public void extract_preview_txt() {
        //        string str;
        //        string str3;
        //        string str4;
        //        if (this.mod_or_installed_or_queue == "M") {
        //            if (this.mod_sevenz_filename == null) {
        //                MyProject.Forms.wizzard_main.description.Text = null;
        //                return;
        //            }
        //            str3 = this.global_data.wizzard_mods_path;
        //            str4 = this.mod_sevenz_filename;
        //        }
        //        else if (this.mod_or_installed_or_queue == "I") {
        //            if (this.installed_mod_sevenz_filename == null) {
        //                MyProject.Forms.wizzard_main.description.Text = null;
        //                return;
        //            }
        //            str3 = this.global_data.wizzard_backups_path;
        //            str4 = this.installed_mod_sevenz_filename;
        //        }
        //        else {
        //            if (this.queue_sevenz_filename == null) {
        //                MyProject.Forms.wizzard_main.description.Text = null;
        //                return;
        //            }
        //            str3 = this.global_data.wizzard_mods_path;
        //            str4 = this.queue_sevenz_filename;
        //        }
        //        if (str4.EndsWith(".7z")) {
        //            str = str4.Remove(str4.Length - 3, 3);
        //        }
        //        else {
        //            if (!(str4.EndsWith(".rar") | str4.EndsWith(".zip"))) {
        //                return;
        //            }
        //            str = str4.Remove(str4.Length - 4, 4);
        //        }
        //        string str2 = str + ".txt";
        //        if (!File.Exists(this.global_data.wizzard_descriptions_path + @"\" + str2)) {
        //            Interaction.Shell(this.global_data.sevenz_exe + " e \"" + str3 + @"\" + str4 + "\" -aoa \"-o" + this.global_data.wizzard_descriptions_path + "\\\" *.txt", AppWinStyle.MinimizedFocus, true, -1);
        //        }
        //        if (this.display_description_txt) {
        //            if (File.Exists(this.global_data.wizzard_descriptions_path + @"\" + str2)) {
        //                StreamReader reader = new StreamReader(this.global_data.wizzard_descriptions_path + @"\" + str2);
        //                MyProject.Forms.wizzard_main.description.Text = reader.ReadToEnd();
        //                reader.Close();
        //            }
        //            else {
        //                MyProject.Forms.wizzard_main.description.Text = "No description found for mod:\r\n" + str;
        //            }
        //        }
        //    }
        //}

        public class CMIDecrypt {
            public static void DecryptBuffer(byte[] buf) {
                int[] numArray = new int[] { 0xca, 110, 13, 0xb3 };
                int[] numArray2 = new int[] { 0x9c, 0x36, 30, 0xe8 };
                int num3 = buf.Length - (buf.Length % 2);
                int index = 0;
                for (int i = 0; i < num3; i += 2) {
                    numArray[index] += numArray2[index];
                    buf[i] = (byte)((buf[i] ^ (numArray[index] & 0xff)) % 0x100);
                    buf[i + 1] = (byte)((buf[i + 1] ^ (numArray[index] >> 8)) % 0x100);
                    index = (index + 1) & 3;
                }
            }

            public static byte[] DecryptFile(string fileName) {
                byte[] buf = File.ReadAllBytes(fileName);
                DecryptBuffer(buf);
                return buf;
            }

            public static void DecryptString(byte[] buf, int start, int length) {
                int num2 = length - 1;
                for (int i = 0; i <= num2; i++) {
                    buf[start + i] = (byte)~buf[start + i];
                }
            }

            public static void WriteFile(string fileName, byte[] buf) {
                File.WriteAllBytes(fileName, buf);
            }
        }

        public class PropertyBaseConverter : StringConverter {
            protected string[] Names = null;

            public PropertyBaseConverter() {
                this.GenNames();
            }

            public override bool CanConvertFrom(ITypeDescriptorContext context, System.Type sourceType) {
                if ((sourceType != typeof(string)) && !base.CanConvertFrom(context, sourceType)) {
                    return false;
                }
                return true;
            }

            public override bool CanConvertTo(ITypeDescriptorContext context, System.Type destinationType) {
                if ((destinationType != typeof(uint)) && !base.CanConvertTo(context, destinationType)) {
                    return false;
                }
                return true;
            }

            public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) {
                if (!(value is string)) {
                    return base.ConvertFrom(context, culture, RuntimeHelpers.GetObjectValue(value));
                }
                int num3 = this.Names.Length - 1;
                for (int i = 0; i <= num3; i++) {
                    if (value.ToString() == this.Names[i]) {
                        return i;
                    }
                }
                return 0;
            }

            public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, System.Type destinationType) {
                if ((destinationType != typeof(string)) || !(value is int)) {
                    return base.ConvertTo(context, culture, RuntimeHelpers.GetObjectValue(value), destinationType);
                }
                if ((this.Names.Length > ((int)value)) && (((int)value) >= 0)) {
                    return this.Names[(int)value];
                }
                return "??";
            }

            protected virtual void GenNames() {
                this.Names = new string[] { "色白", "普通", "褐色", "色黒" };
            }

            public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) {
                return new TypeConverter.StandardValuesCollection(this.Names);
            }

            public override bool GetStandardValuesSupported(ITypeDescriptorContext context) {
                return true;
            }
        }

        public class PropertyBaseConverter_byte : StringConverter {
            protected string[] Names = null;

            public PropertyBaseConverter_byte() {
                this.GenNames();
            }

            public override bool CanConvertFrom(ITypeDescriptorContext context, System.Type sourceType) {
                if ((sourceType != typeof(string)) && !base.CanConvertFrom(context, sourceType)) {
                    return false;
                }
                return true;
            }

            public override bool CanConvertTo(ITypeDescriptorContext context, System.Type destinationType) {
                if ((destinationType != typeof(byte)) && !base.CanConvertTo(context, destinationType)) {
                    return false;
                }
                return true;
            }

            public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) {
                if (!(value is string)) {
                    return base.ConvertFrom(context, culture, RuntimeHelpers.GetObjectValue(value));
                }
                int num3 = this.Names.Length - 1;
                for (int i = 0; i <= num3; i++) {
                    if (value.ToString() == this.Names[i]) {
                        return (byte)i;
                    }
                }
                return 0;
            }

            public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, System.Type destinationType) {
                if ((destinationType != typeof(string)) || !(value is byte)) {
                    return base.ConvertTo(context, culture, RuntimeHelpers.GetObjectValue(value), destinationType);
                }
                if ((this.Names.Length > ((byte)value)) && (((byte)value) >= 0)) {
                    return this.Names[(byte)value];
                }
                return "??";
            }

            protected virtual void GenNames() {
                this.Names = new string[] { "色白", "普通", "褐色", "色黒" };
            }

            public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) {
                return new TypeConverter.StandardValuesCollection(this.Names);
            }

            public override bool GetStandardValuesSupported(ITypeDescriptorContext context) {
                return true;
            }
        }


    }
}

